<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>- 后台登录 -</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="/static/css/style.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="gray-bg">
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
               <!-- <h1 class="logo-name">教务管理系统</h1>-->
                <h2>教务管理系统</h2>
                
            </div>
            <form onsubmit="return false" class="m-t" method="POST" role="form">
                <div class="form-group">
                    <input type="text" class="form-control" name="user_name" placeholder="用户名" >
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" name="password" placeholder="密码" >
                </div>
                <!-- <div class="form-group">
                    <input  >
                    <img id="captcha" onclick="fleshVerify()" src="{:url('/manage/verify')}" style="cursor: pointer;" />
                </div> -->
                <!-- <div class="form-group" id="googl_code">
                    <input type="text" style="width:50%;" class="form-control" name="googl_code" placeholder="谷歌验证码" >
                </div> -->
                <input type="submit" onclick="login()" class="btn btn-primary btnSubmit block full-width m-b" value="登 录" />
            </form>
        </div>
    </div>
    <!-- 全局js -->
    <script src="/static/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/js/plugins/layer/layer.min.js"></script>
</body>
<script type="text/javascript">
    //重载验证码
    function fleshVerify(){
        $('#captcha').attr('src','/manage/verify?nonce_str='+Math.floor(Math.random()*100));
    }
   
    //去空格
    function trim(str){
        return str.replace(/(^\s*)|(\s*$)/g, "");
    }
    //登录
    function login(){
        var user_name = $("input[name='user_name']").val();
        var password = $("input[name='password']").val();
        // var code = $("input[name='code']").val();
        var googl_code = $("input[name='googl_code']").val();
        if(trim(user_name) == ""){
            parent.layer.msg("账号不能为空");
            return false;
        }
        if(trim(password) == ""){
            parent.layer.msg("密码不能为空");
            return false;
        }
        // if(trim(code) == ""){
        //     parent.layer.msg("验证码不能为空");
        //     return false;
        // }
        // if(trim(user_name) == "admin"){
        //     if(trim('googl_code') == ''){
        //         parent.layer.msg("谷歌验证码不能为空");
        //     return false;
        //     }
        // }
        $.ajax({
            url: "{:url('/manage/checkLogin')}",
            type:"POST",
            dataType:"json",
            data:{user_name:user_name,password:password,googl_code:googl_code},
            beforeSend:function(data){
                $(".btnSubmit").attr({ disabled: "disabled" });
                index = parent.layer.load(0, {shade: false});
            },
            success: function(data){
                parent.layer.msg(data.msg);
                if(data.code == 1){
                    setTimeout(function(){
                        window.location.href=data.url;
                    },1000);
                }
            },
            error: function(data){
                //fleshVerify();//刷新验证码
                parent.layer.msg('网络失败，请刷新页面后重试!');
            },
            complete: function () {
                $(".btnSubmit").removeAttr("disabled");
                parent.layer.close(index);
                
            }
        })
    }
</script>
</html>
